﻿using Omu.ValueInjecter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace SerializerBenchmark
{
    public class EntityToDictionaryInjection:KnownTargetValueInjection<Dictionary<string,string>>//KnownSourceValueInjection<POCOEntity>
    {
        protected override void Inject(object source, ref Dictionary<string, string> target)
        {
            if (target==null)
            {
                target = new Dictionary<string, string>();
            }
            PropertyInfo[] props = source.GetType().GetProperties();
            foreach(PropertyInfo pi in props)
            {
                //var targetProp = target.GetProps().GetByName(source.GetName(i), true);
                if (pi == null) continue;

                var value = pi.GetValue(source);

                target[pi.Name] = value + string.Empty;
                //targetProp.SetValue(target, value);
            }
        }
    }
}
